package com.example.seakdreamandroid.lottery;


import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.example.seakdreamandroid.R;

/**
 * Created by huahen on 2021/10/25
 * ClassDescription : 抽奖转盘-奖品子view
 */
public class PrizeItemView extends FrameLayout implements PrizeItemApi {

    private Context mContext;
    private View mOverlay;
    private ImageView ivPrize;
    private TextView tvPrize;

    public PrizeItemView(@NonNull Context context) {
        this(context, null);
    }


    public PrizeItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public PrizeItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        inflate(context, R.layout.lottery_prizeitemview, this);
        mOverlay = findViewById(R.id.overlay);
        ivPrize = findViewById(R.id.iv_prize);
        tvPrize = findViewById(R.id.tv_prize_name);
        mContext = context;
    }


    @Override
    public void setFocus(boolean isFocused) {
        if (mOverlay != null) {
            mOverlay.setVisibility(isFocused ? INVISIBLE : VISIBLE);
        }
    }

    @Override
    public void setUi(PrizeListBean bean) {
        Glide.with(mContext).load(bean.getPrize_path()).into(ivPrize);
        tvPrize.setText(bean.getGoodName());
    }
}

